package com.zodiac.alioth.web.config;

import com.zodiac.alioth.web.security.AppAuthFilter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.servlet.Filter;

/**
 * @author insight
 */
@Configuration
@EnableAutoConfiguration
public class SecurityConfig {

    @Bean
    public FilterRegistrationBean authContextFilterRegistration() {

        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(authContextFilter());
        registration.addUrlPatterns("/*");
        registration.setName("authContextFilter");
        registration.setOrder(3);
        return registration;
    }

    @Bean
    public Filter authContextFilter() {
        return new AppAuthFilter("/noAuth", "/login", "/logout");
    }

}
